package com.ledi.guns.modular.ledipay.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ledi.guns.common.persistence.dao.RegionMapper;
import com.ledi.guns.common.persistence.model.Region;
import com.ledi.guns.common.persistence.model.vo.RegionVo;
import com.ledi.guns.modular.ledipay.controller.req.region.QueryRegion;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> {

	@Resource
	private RegionMapper regionMapper;

	//	@Cacheable(value = "searchProvince")
	public List<RegionVo> getProvince() {

		List<RegionVo> regionVos = regionMapper.getProvince();
		return regionVos;
	}

	//	@Cacheable(value = "searchCity", key = "#queryRegion.code")
	public List<RegionVo> getCity(QueryRegion queryRegion) {

		List<RegionVo> regionVos = regionMapper.getCity(queryRegion.getCode());
		return regionVos;
	}

	//	@Cacheable(value = "searchArea", key = "#queryRegion.code")
	public List<RegionVo> getArea(QueryRegion queryRegion) {

		List<RegionVo> regionVos = regionMapper.getarea(queryRegion.getCode());
		return regionVos;
	}

	public String getNameByCode(String code) {

		String name = regionMapper.getNameByCode(code);
		return name;
	}

	public String getCodeByName(String name) {

		return regionMapper.getCodeByName(name);
	}
}
